import request from '@/utils/request'
import { AxiosPromise } from 'axios'

// apiUrl 流程表单分类
const api = {
	update: '/v1/form-template/update', // id修改信息
	page: '/v1/form-template/page', // 分页列表
	delete: '/v1/form-template/delete', // 根据ids删除
	create: '/v1/form-template/create', // 创建
	getOneDetail: '/v1/form-template/get', // 查询id信息
	getSimpleList: '/v1/form-template/page-simple' // 分页列表 简单
}

function formTemplatePageApi(data: any): AxiosPromise {
	return request({
		url: api.page,
		method: 'post',
		data
	})
}

function formTemplateSimpleListApi(data: any): AxiosPromise {
	return request({
		url: api.getSimpleList,
		method: 'post',
		data
	})
}

function formTemplateAddOrEditSaveApi(data: any): AxiosPromise {
	return request({
		url: data.id ? api.update : api.create,
		method: 'post',
		data
	})
}

function formTemplateDeleteApi(data: any): AxiosPromise {
	return request({
		url: api.delete,
		method: 'post',
		data
	})
}

function formTemplateDetailApi(id: any): AxiosPromise {
	return request({
		url: `${api.getOneDetail}?id=${id}`,
		method: 'get'
	})
}

export default {
	formTemplatePageApi,
	formTemplateAddOrEditSaveApi,
	formTemplateDeleteApi,
	formTemplateDetailApi,
	formTemplateSimpleListApi
}
